/**
 @file ctc_asw_linkagg.h

 @author  Copyright (C) 2020 Centec Networks Inc.  All rights reserved.

 @date 2020-06-15

 @version v1.0

 The file define  CENTEC SDK  chip

 This module is designed to support Link Aggregation function by which many Ethernet ports can be bundled together to form a linkagg port. The linkagg
 is regarded as one logical link, and is useful when a high bandwidth and/ or redundancy between switches are required.
 All ports in a linkagg must be configured with the same speed and the transmission mode for each linkagg member port
 must be set to full-duplex.

 \b
 \p
 Linkagg  provide features below:
 \d Static Load balance.
\b
\p
\B Static Load balance.
\p
 Supports up to 5 link aggregation group and 1 linkagg mode:
\p
 denotes how many linkagg groups, [M] denotes how many linkagg member ports per group.
\p
 Port Selection Criteria (PSC) are used to spread the traffic across the linkagg's member ports by different hash value,
 hash key can be macsa, macda, ipsa, ipda and others, you can use ctc_linkagg_set_psc() to set port selection criteria.

\b
 \S ctc_linkagg.h:ctc_linkagg_psc_l2_header_t
 \S ctc_linkagg.h:ctc_linkagg_psc_ip_header_t
 \S ctc_linkagg.h:ctc_linkagg_psc_l4_header_t
 \S ctc_linkagg.h:ctc_linkagg_psc_type_t
 \S ctc_linkagg.h:ctc_linkagg_psc_t

*/
#ifndef _CTC_ASW_LINKAGG_H
#define _CTC_ASW_LINKAGG_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************
*
* Header Files
*
****************************************************************************/
#include "ctc_linkagg.h"


/***************************************************************************
*
* Defines and Macros
*
****************************************************************************/


/***************************************************************************
*
*  Functions
*
****************************************************************************/
/**
 @brief Add a port to linkagg

 @param[in] lchip    local chip id

 @param[in] tid the linkagg id wanted to operate

 @param[in] gport global port of the member port which to added

 @remark[TMA]  Add a member port to a exist linkagg group with the given tid and gport.
\p
          The specified linkagg group must be one returned from ctc_linkagg_create().
\d        If the port is already exist in linkagg group, add member port operation will fail.
\d        If the linkagg already has members, they will be retained.

 @return CTC_E_XXX

*/
extern int32
ctc_asw_linkagg_add_port(uint8 lchip, uint16 tid, uint32 gport);

/**
 @brief Remove the port from linkagg

 @param[in] lchip    local chip id

 @param[in] tid the linkagg id wanted to operate

 @param[in] gport global port of the member port which to be removed

 @remark[TMA]  Remove a member port from a exist linkagg group with the given tid and gport.
                The specified linkagg group must be one returned from ctc_linkagg_create().
\p
                The port wanted to remove must be a member of the linkagg.
\d        If the port is not exist in linkagg group, add member port operation will fail.
\d        If the linkagg has members, they will be remove.


 @return CTC_E_XXX

*/
extern int32
ctc_asw_linkagg_remove_port(uint8 lchip, uint16 tid, uint32 gport);

/**
 @brief Get the member ports from a linkagg

 @param[in] lchip    local chip id

 @param[in] tid the linkagg id wanted to operate

 @param[out] p_gports a global member ports list of linkagg group

 @param[out] cnt       the number of linkagg member

 @remark[TMA]  Get the member ports of a exist linkagg group with the given tid.
                The specified linkagg group must be one returned from ctc_linkagg_create().
                The member ports  list of linkagg group is stored in array pointer p_gports.
                The p_gports memory must be allocated by user and the array num is 1024/groupNum.

 @return CTC_E_XXX

*/
extern int32
ctc_asw_linkagg_get_member_ports(uint8 lchip, uint16 tid, uint32* p_gports, uint16* cnt);

/**
 @brief Set member of linkagg hash key

 @param[in] lchip    local chip id

 @param[in] psc the port selection criteria of linkagg hash

 @remark[TMA]  Set the global linkagg's Port Selection Criteria (PSC), members of linkagg hash key included.
                Assigns a particular load balancing hash algorithm.


 @return CTC_E_XXX

*/
extern int32
ctc_asw_linkagg_set_psc(uint8 lchip, ctc_linkagg_psc_t* psc);

/**
 @brief Get member of linkagg hash key

 @param[in] lchip    local chip id

 @param[in|out] psc the port selection criteria of linkagg hash

 @remark[TMA]  Get the global linkagg's Port Selection Criteria (PSC), members of linkagg hash key included.

 @return CTC_E_XXX

*/
extern int32
ctc_asw_linkagg_get_psc(uint8 lchip, ctc_linkagg_psc_t* psc);


/**
 @brief Init the linkagg module

 @param[in] lchip    local chip id

 @param[in]  linkagg_global_cfg linkagg global config information

 @remark  Initialize the linkagg module, including global variable, soft table, asic table, etc.
                This function has to be called before any other linkagg functions.

 @return CTC_E_XXX

*/
extern int32
ctc_asw_linkagg_init(uint8 lchip, void* linkagg_global_cfg);

/**
 @brief De-Initialize linkagg module

 @param[in] lchip    local chip id

 @remark[TMA  User can de-initialize the linkagg configuration

 @return CTC_E_XXX
*/
extern int32
ctc_asw_linkagg_deinit(uint8 lchip);
/**@} end of @defgroup   */
#ifdef __cplusplus
}
#endif

#endif

